import express from 'express';
import { uploadImg, getIpSaveImg, getSaveNum, getAllImg, deleteImg } from "../controller/img.controller.js"
import { handleImage, resizeUserPhoto, protectStorage } from "../middleware/img.middlerware.js"

const imageRouter = express.Router()

// 上传图片
imageRouter
  .route('/upload')
  .get(getIpSaveImg)
  .post(protectStorage, handleImage, resizeUserPhoto, uploadImg)
  .delete(deleteImg)


// 获取保存的图片数 | 获取所有保存的图片列表
imageRouter
  .route('/imgs')
  .get(getSaveNum)
  .post(getAllImg)

export default imageRouter
